<script>
export default {
  name: "Student",
  data() {
    return {msg: 'Live and learn', myAge: this.age}
  },

  methods:{
    updateAge(){
      //this.age = this.age + 1;
      this.myAge = this.myAge+1;
    }
  },
  //简单设声明接收
  //props: ['name','age', 'sex'],

  //对数据类型限制
 /* props:{
    name:String,
    age:Number,
    sex:String
  },*/

  props:{
    name:{type:String,required:true},
    age:{type:Number,default:99},
    sex:{type:String,required:true}
  }

}
</script>

<template>
  <div>
    <h1>标语:{{ msg }}</h1>
    <h2>学生姓名:{{ name }}</h2>
    <h2>学生年龄:{{ myAge }}</h2>
    <h2>学生性别:{{ sex }}</h2>
    <button @click="updateAge">年龄+1</button>
  </div>
</template>

<style scoped>

</style>
